# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Karol "Kenji Takahashi" Woźniak <kenji.sx>
# Contributor: spider-mario <spidermario@free.fr>
# Contributor: Allen Li <darkfeline at abagofapples.com>

pkgname=flake8
pkgver=6.1.0
pkgrel=1
epoch=1
pkgdesc="The modular source code checker: pep8, pyflakes and co"
arch=('any')
url="https://flake8.pycqa.org"
license=('MIT')
depends=('python-pyflakes' 'python-mccabe' 'python-pycodestyle' 'python-entrypoints')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
source=("https://github.com/PyCQA/flake8/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('a44d245b023acbb89e64071f6cb76f5543e538472a8815fa329a3b3671133cc6f96f246d83877a2a9ac91c32ecdf65858f8edf996efba77906af74b1632b74c8')

prepare() {
  sed -i -e 's/,<[0-9=.]*//' flake8-$pkgver/setup.cfg

  sed -i '/error/a \    ignore:Creating a LegacyVersion has been deprecated and will be removed in the next major release:DeprecationWarning' flake8-$pkgver/pytest.ini
}

build() {
  cd flake8-$pkgver
  python setup.py build
}

check() {
  # Hack entry points by installing it

  cd flake8-$pkgver
  python setup.py install --root="$PWD/tmp_install" --optimize=1
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  PYTHONPATH="$PWD/tmp_install/usr/lib/python${python_version}/site-packages:$PYTHONPATH" pytest
}

package() {
  cd flake8-$pkgver
  python setup.py install --root="$pkgdir" --prefix=/usr --optimize=1
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
